package com.lb.design.pattern.singleton.lazy;

/**
 * @author lb
 * @Title: LazyInnerclassSingleton
 * @Description: TODO
 * @date 2019/03/12  13:56
 */
public class LazyInnerclassSingleton {
    private static LazyInnerclassSingleton lazyInnerclassSingieton = null;
    private LazyInnerclassSingleton(){
        if (LazyHolder.lazyInnerclassSingieton !=null){
            throw new RuntimeException("不允许创建多个实例");
        }
    }
    //static 是为了使单例的空间共享
    //final 保证这个方法不会被重写，重载
    public static final LazyInnerclassSingleton getInstance(){
        return LazyHolder.lazyInnerclassSingieton;
    }
    private static class LazyHolder{
        private static final LazyInnerclassSingleton lazyInnerclassSingieton= new LazyInnerclassSingleton();
    }
}
